package com.cskaoyan._08game._02pvz;

/**
 * @description:
 * @author: 景天
 * @date: 2023/2/6 9:45
 **/
/*
用面向对象的思想模拟植物大战僵尸
 */
public class Demo {
    public static void main(String[] args) {
        // 测试
        // 创建植物对象
        Plant plant = new Plant("豌豆射手", 50, 10, 100);
        // 创建僵尸对象
        Zombie zombie = new Zombie("普通僵尸", 20, 1000, 1);

        // 2个对象持有对方的引用
        plant.zombie = zombie;
        zombie.plant = plant;

        // 相互攻击
        plant.attack();
        zombie.beAttacked();

        plant.attack();
        zombie.beAttacked();

        zombie.attack();
        plant.beAttacked();

        zombie.attack();
        plant.beAttacked();

        // 僵尸移动
        zombie.move();

        // 吃掉脑子
        zombie.eat();
    }
}
